import { AfterViewInit, Directive, ElementRef, Input, Renderer2 } from '@angular/core';

@Directive({
  selector: '[appTitle]'
})
export class TitleDirective implements AfterViewInit {
  @Input() appTitle: string;
  constructor(
    private el: ElementRef,
    private render: Renderer2
  ) {
  }

  ngAfterViewInit() {
    this.render.setAttribute(this.el.nativeElement, 'title', this.appTitle);
  }
}
